package cn.zhuoluodada.opensource.smartdb.sqlbuilder.impl.postgresql;

import cn.zhuoluodada.opensource.smartdb.SmartDb;
import cn.zhuoluodada.opensource.smartdb.sqlbuilder.*;
import cn.zhuoluodada.opensource.smartdb.sqlbuilder.*;
import cn.zhuoluodada.opensource.smartdb.sqlbuilder.convertor.ColumnNameConverter;
import cn.zhuoluodada.opensource.smartdb.sqlbuilder.convertor.TableNameConverter;

public class PostgreSqlSqlBuilderFactory implements SqlBuilderFactory {

    @Override
    public InsertSqlBuilder insert(TableNameConverter tableNameConverter, ColumnNameConverter columnNameConverter) {
        return new PostgreSqlInsertSqlBuilder(tableNameConverter, columnNameConverter);
    }

    @Override
    public UpdateSqlBuilder update(TableNameConverter tableNameConverter, ColumnNameConverter columnNameConverter) {
        return new PostgreSqlUpdateSqlBuilder(tableNameConverter, columnNameConverter);
    }

    @Override
    public DeleteSqlBuilder delete(TableNameConverter tableNameConverter, ColumnNameConverter columnNameConverter) {
        return new PostgreSqlDeleteSqlBuilder(tableNameConverter, columnNameConverter);
    }

    @Override
    public SelectSqlBuilder select(TableNameConverter tableNameConverter, ColumnNameConverter columnNameConverter) {
        return new PostgreSqlSelectSqlBuilder(tableNameConverter, columnNameConverter);
    }

    @Override
    public InsertSqlBuilder insert(SmartDb smartDb) {
        return new PostgreSqlInsertSqlBuilder(smartDb);
    }

    @Override
    public UpdateSqlBuilder update(SmartDb smartDb) {
        return new PostgreSqlUpdateSqlBuilder(smartDb);
    }

    @Override
    public DeleteSqlBuilder delete(SmartDb smartDb) {
        return new PostgreSqlDeleteSqlBuilder(smartDb);
    }

    @Override
    public SelectSqlBuilder select(SmartDb smartDb) {
        return new PostgreSqlSelectSqlBuilder(smartDb);
    }

    @Override
    public String wrapSpecialCharacterField(String field) {
        StringBuilder sb = new StringBuilder();
        return sb.append(PostgreSqlConst.RESERVED_WORD_CHAR).append(field).append(PostgreSqlConst.RESERVED_WORD_CHAR).toString();
    }

}
